define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
	
	$scope.form.fk_client =params.fk_client;
	$scope.find=function(){
		httpService.post(app.urls.menu_select,$scope.form,function(data){
			if("0000" === data.code){
				$scope.menus = data.data;
				$scope.findbutton();
			}else{
				alert(data.msg);
			}
		});
	}
	
	$scope.findbutton=function(){
		httpService.post(app.urls.button_selectByApp,$scope.form,function(data){
			if("0000" === data.code){
				$scope.buttons = data.data;
			}else{
				alert(data.msg);
			}
		});
	}
	
	var init= function(){
		$scope.find();
	}
	init();
	
	//添加菜单
	$scope.addMenu=function(){
		eventBusService.publish("modal.page","modules/content/syssetting/appsetting/menuAndButton/addMenu?FatherControllerName="+$scope.controllerName+"&fk_client="+$scope.form.fk_client);
	}
	//添加子菜单
	$scope.addSonMenu=function(row){
		eventBusService.publish("modal.page","modules/content/syssetting/appsetting/menuAndButton/addSonMenu?FatherControllerName="+$scope.controllerName+"&fk_client="+$scope.form.fk_client+"&father_id="+row.id);
	}
	//添加按钮
	$scope.addButton=function(row){
		eventBusService.publish("modal.page","modules/content/syssetting/appsetting/menuAndButton/addButton?FatherControllerName="+$scope.controllerName+"&fk_menuid="+row.id);
	}
	//编辑菜单
	$scope.updateMenu=function(row){
		eventBusService.publish("modal.page","modules/content/syssetting/appsetting/menuAndButton/updateMenu?FatherControllerName="+$scope.controllerName+"&id="+row.id);
	}
	//编辑按钮
	$scope.updateButton=function(row){
		eventBusService.publish("modal.page","modules/content/syssetting/appsetting/menuAndButton/updateButton?FatherControllerName="+$scope.controllerName+"&id="+row.id);
	}
	$scope.menuimport=function(){
		eventBusService.publish("modal.page","modules/content/syssetting/appsetting/menuAndButton/menuimport?fk_client="+params.fk_client);
	}
	$scope.menuexport=function(){
		httpService.post(app.urls.menu_export,{"fk_client":params.fk_client}, function(data) {
			if ("0000" === data.code) {
				window.location.href = data.data;
			} else {
				alert(data.msg);
			}
		});
	}
	$scope.buttonimport=function(){
		eventBusService.publish("modal.page","modules/content/syssetting/appsetting/menuAndButton/buttonimport");
	}
	$scope.buttonexport=function(){
		httpService.post(app.urls.button_export,{"fk_client":params.fk_client}, function(data) {
			if ("0000" === data.code) {
				window.location.href = data.data;
			} else {
				alert(data.msg);
			}
		});
	}
	//返回
	$scope.goback = function(){
		var menu = {};
		menu.url = "modules/content/syssetting/appsetting?fk_menuid="+params.fk_menuid+"&father_id="+params.father_id;
		eventBusService.publish("modules.content.load",menu);
	}
	//接收数据刷新
	eventBusService.subscribe('content.page.reload', function(event,data) {
		$scope.find();
    });
	      
}}});